function f = flipdim(f,dim)
%FLIPDIM Flip/reverse a chebfun2 in a chosen direction.
% 
% G = FLIPDIM(F,DIM) returns a chebfun2 G with the same domain as F but 
% reversed in a direction, i.e., G(x,y)=F(x,c+d-y). If DIM = 2 (default) 
% then G(x,y) = F(x,c+d-y).  Otherwise DIM=1 and G(x,y)=F(a+b-x,y). 
% The domain of F is [a,b,c,d]. 
% 
% See also FLIPLR, FLIPUD.

% Copyright 2013 by The University of Oxford and The Chebfun Developers.
% See http://www.maths.ox.ac.uk/chebfun/ for Chebfun information. 

%%
% Use the code in flipud and fliplr. 
if ( dim == 1 )
    f = flipud(f); 
elseif ( dim == 2 )
    f = fliplr(f); 
else
    error('CHEBFUN2:FLIPDIM:DIM','Dimension not recognised');
end

end